package com.example.demo.mapper;

import com.example.demo.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    /*查询所有的用户信息*/
    /*在查询中，一律不可以使用*号作为查询字段,需要什么字段必须说明*/
    @Select("select username, password, banned, admin from users")
    List<User> findAllUsers();

    @Select("select username, password, banned, admin from users where username=#{username}")
    User findAUsers(String username);

    @Delete("delete from users where username=#{username}")
    int deleteAUsers(String username);

    @Insert("insert into users(username, password, banned, admin) values (#{username}, #{password}, #{banned}, #{admin})")
    int insertAUsers(User user);

    @Update("update user set password = #{password} where username = #{username}")
    int changePWD(String username, String pwd);


//    int deleteByPrimaryKey(Long id);
//
//    int insert(User record);
//
//    int insertSelective(User record);
//
//    User selectByPrimaryKey(Long id);
//
//    int updateByPrimaryKeySelective(User record);
//
//    int updateByPrimaryKey(User record);
}

